use crate::lib::Summary;
use anyhow::Result;
#[derive(Debug)]
pub struct NewsArticle {
    pub headline: String,
    pub location: String,
    pub author: String,
    pub content: String,
}

impl Summary for NewsArticle {
    fn summarize(&self) -> String {
        format!("{}, by {} ({})", self.headline, self.author, self.location)
    }
}

impl Drop for NewsArticle {
    fn drop(&mut self) {
        println!("Dropping NewsArticle");
    }
}

#[derive(Debug)]
pub struct Tweet {
    pub username: String,
    pub content: String,
    pub reply: bool,
    pub retweet: bool,
}

impl Summary for Tweet {
    fn summarize(&self) -> String {
        format!("{}: {}", self.username, self.content)
    }
}

pub fn ab_impl() {
    let tw = Tweet {
        username: String::from("horse_ebooks"),
        content: String::from("of course, as you probably already know, people"),
        reply: false,
        retweet: false,
    };
    println!("1 new tweet: {}", tw.summarize());
}

pub mod ab_t {
    use crate::lib::Summary;
    use std::fmt::{Debug, Display};
    pub fn notify<T: Summary>(item1: &T, item2: &T) {
        todo!()
    }

    pub fn notify_mut<T: Summary + Display>(item: &T) {
        todo!()
    }

    fn some_function<T: Display + Clone, U: Clone + Debug>(t: &T, u: &U) -> i32 {
        todo!()
    }

    fn some_func<T, U>(t: &T, u: &U) -> i32
    where
        T: Display + Clone,
        U: Clone + Debug,
    {
        todo!()
    }

    fn get_summarizable() -> impl Summary {
        super::Tweet {
            username: String::from("horse_ebooks"),
            content: String::from("of course, as you probably already know, people"),
            reply: false,
            retweet: false,
        }
    }
}
